<?php
class Zend_Validate_DateLessThan extends Zend_Validate_Abstract
{
 
    const NOT_LESS = 'notLessThan';
 
    protected $_messageTemplates = array(
        self::NOT_LESS => "'%value%' is not less than '%max%'"
    );
 
    protected $_messageVariables = array(
        'max' => '_max'
    );
 
    protected $_max;
 
    protected $_inclusive;
     
    protected $_datePart;
 
    public function __construct( Zend_Date $max, $datePart = Zend_Date::TIMESTAMP )
    {
        $this->setMax( $max )
             ->setDatePart( $datePart );
    }
 
    public function getMax()
    {
        return $this->_max;
    }
 
    public function setMax( Zend_Date $max )
    {
        $this->_max = $max;
        return $this;
    }
 
    public function getDatePart()
    {
        return $this->_datePart;
    }
 
    public function setDatePart( $datePart )
    {
        $this->_datePart = $datePart;
        return $this;
    }
 
    public function isValid( $value )
    {
        if( !$value instanceof Zend_Date )
        {
            try
            {
                $value = new Zend_Date( $value );
            }
            catch( Exception $exception )
            {
                require_once 'Zend/Validate/Exception.php';
                throw new Zend_Validate_Exception( $exception->getMessage() );
            }
        }
 
        $this->_setValue( $value );

        if( $this->_max->isEarlier( $value, $this->_datePart ) )
        {
            $this->_error( self::NOT_LESS );
            return false;
        }
        return true;
    }
 
}